///PHILOTES Source Code.  (C)2012 PhiloLabs
#pragma once


#include "ExtrasPrerequisites.h "

#include "OverlayContainer.h"

namespace Extras {


    class _PhiloExtrasExport PanelOverlayElement : public OverlayContainer
    {
    public:
        
        PanelOverlayElement(const Ogre::String& name);
        virtual ~PanelOverlayElement();

        virtual void initialise(void);

        void setTiling(Real x, Real y, ushort layer = 0);

        Real getTileX(ushort layer = 0) const;
        
        Real getTileY(ushort layer = 0) const;

        void setUV(Real u1, Real v1, Real u2, Real v2);

        void getUV(Real& u1, Real& v1, Real& u2, Real& v2) const;

        void setTransparent(bool isTransparent);

        bool isTransparent(void) const;

        virtual const Ogre::String& getTypeName(void) const;
        
        void getRenderOperation(RenderOperation& op);
        
        void setMaterialName(const Ogre::String& matName);
        
        void _updateRenderQueue(RenderQueue* queue);



        class CmdTiling : public ParamCommand
        {
        public:
            Ogre::String doGet(const void* target) const;
            void doSet(void* target, const Ogre::String& val);
        };
        
        class CmdTransparent : public ParamCommand
        {
        public:
            Ogre::String doGet(const void* target) const;
            void doSet(void* target, const Ogre::String& val);
        };
        
        class CmdUVCoords : public ParamCommand
        {
        public:
            Ogre::String doGet(const void* target) const;
            void doSet(void* target, const Ogre::String& val);
        };
    protected:
        // Flag indicating if this panel should be visual or just group things
        bool mTransparent;
        // Texture tiling
        Real mTileX[OGRE_MAX_TEXTURE_LAYERS];
        Real mTileY[OGRE_MAX_TEXTURE_LAYERS];
        size_t mNumTexCoordsInBuffer;
        Real mU1, mV1, mU2, mV2;

        RenderOperation mRenderOp;

        /// internal method for setting up geometry, called by OverlayElement::update
        virtual void updatePositionGeometry(void);

        /// Called to update the texture coords when layers change
        virtual void updateTextureGeometry(void);

        /// Method for setting up base parameters for this class
        void addBaseParameters(void);

        static Ogre::String msTypeName;

        // Command objects
        static CmdTiling msCmdTiling;
        static CmdTransparent msCmdTransparent;
        static CmdUVCoords msCmdUVCoords;

    };
	
}

